package com.zrf.gulimall.search.controller;

import com.zrf.gulimall.commnon.core.es.SkuEsModel;
import com.zrf.gulimall.commnon.core.exception.StatusCode;
import com.zrf.gulimall.commnon.core.utils.R;
import com.zrf.gulimall.search.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @Author zhanrf
 * @Date 2021/12/19 1:24
 */
@RestController
@RequestMapping("/elastic")
public class ElasticController {
	@Autowired
	private ProductService productService;

	@PostMapping("/product/up")
	public R productStatusUp(@RequestBody List<SkuEsModel> skuEsModels) throws IOException {
		boolean b = productService.productStatusUp(skuEsModels);
		if (b) {
			return R.ok();
		} else {
			return R.error(StatusCode.PRODUCT_UP_EXCEPTION.getCode(), StatusCode.PRODUCT_UP_EXCEPTION.getMsg());
		}
	}
}
